package com.ccrfid.rmc6.resource.sys;

import com.ccrfid.rmc6.appconfig.exception.pojo.AppException;
import com.ccrfid.rmc6.entity.sys.DictEntity;
import com.ccrfid.rmc6.entity.sys.DictTypeEntity;
import com.ccrfid.rmc6.service.sys.DictService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;

import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;
import java.util.List;

@Path("")
@Produces(MediaType.APPLICATION_JSON)
public class DictResource {
    private static final Logger logger = LoggerFactory.getLogger(DictResource.class);
    @Autowired
    private DictService dictService;

    //获取所有字典类型信息
    @GET
    @Path("dict/types")
    public List<DictTypeEntity> getDictTypeList() {
        List<DictTypeEntity> list = dictService.getDictTypeList();
        return list;
    }

    //获取所有字典值
    @GET
    @Path("dicts")
    public List<DictEntity> getDictList() {
        List<DictEntity> list = dictService.getDictList();
        return list;
    }

    //获取某个类型的所有字典值
    @GET
    @Path("dicts/type/{typeId}")
    public List<DictEntity> getDictByType(@PathParam("typeId") Integer typeId) {
        List<DictEntity> list = dictService.getDictByType(typeId);
        return list;
    }

    //获取某个字典值
    @GET
    @Path("dicts/{dictId}")
    public DictEntity getDict(@PathParam("dictId") Integer id) {
        DictEntity dictEntity = dictService.getDict(id);
        return dictEntity;
    }

    //更新某个字典值
    @PUT
    @Path("dicts/{dictId}")
    @Consumes(MediaType.APPLICATION_JSON)
    public DictEntity updateDict(@PathParam("dictId") Integer id, DictEntity entity) throws AppException {
        DictEntity dictEntity = dictService.updateDict(id, entity);
        return dictEntity;
    }

    //获取字典值的子类型值
    @GET
    @Path("dicts/{dictId}/subs")
    public List<DictEntity> getSubDictList(@PathParam("dictId") Integer id) {
        List<DictEntity> list = dictService.getDictAndSubDictListById(id);
        return list;
    }

    //获取重点关注犯人类型
    @GET
    @Path("dict/focused-prisoner-types")
    public List<DictEntity> getFocusedPrisonerTypes() {
        List<DictEntity> list = dictService.getFocusedPrisonerTypes();
        return list;
    }

    //获取管教类型
    @GET
    @Path("dict/room-manager-types")
    public List<DictEntity> getRoomManagerTypes() {
        return dictService.getRoomManagerTypes();
    }

    //获取人员类型
    @GET
    @Path("dict/personnel-types")
    public List<DictEntity> getPersonnelTypes() {
        return dictService.getPersonnelTypes();
    }

    //获取人员类型及其子类型
    @GET
    @Path("dict/personnel-types-with-subs")
    public List<DictEntity> getPersonnelTypeWithSubs() {
        return dictService.getPersonnelTypeWithSubs();
    }

    //获取所有区域类型
    @GET
    @Path("dict/location-types")
    public List<DictEntity> getLocationTypes() {
        return dictService.getLocationTypes();
    }

    //获取告警级别
    @GET
    @Path("dict/alarm-levels")
    public List<DictEntity> getAlarmLevels() {
        return dictService.getAlarmLevels();
    }

    //获取告警类型
    @GET
    @Path("dict/alarm-types")
    public List<DictEntity> getAlarmTypes() {
        return dictService.getAlarmTypes();
    }

    //获取布防类型
    @GET
    @Path("dict/guard-types")
    public List<DictEntity> getGuardTypes() {
        return dictService.getGuardTypes();
    }

    //获取告警联动方式
    @GET
    @Path("dict/alarm-linkage-modes")
    public List<DictEntity> getAlarmLinkageModes() {
        return dictService.getAlarmLinkageModes();
    }

    //获取视频平台添加时可用的平台类型
    @GET
    @Path("dict/video-platform-types")
    public List<DictEntity> getVideoPlatformTypes() {
        return dictService.getVideoPlatformTypes();
    }

    //获取摄像头添加时可用的设备类型
    @GET
    @Path("dict/video-camera-types")
    public List<DictEntity> getVideoCameraTypes() {
        return dictService.getVideoCameraTypes();
    }

    //获取某个视频类型值的可选的版本类型
    @GET
    @Path("dict/{dictId}/video-versions")
    public List<DictEntity> getVideoVersions(@PathParam("dictId") Integer dictId) {
        return dictService.getVideoVersions(dictId);
    }

    //获取摄像头外观类型
    @GET
    @Path("dict/video-camera-shapes")
    public List<DictEntity> getVideoCameraShapes() {
        return dictService.getVideoCameraShapes();
    }

    //获取树节点类型：目录/节点
    @GET
    @Path("dict/node-types")
    public List<DictEntity> getNodeTypes() {
        return dictService.getNodeTypes();
    }
}
